var MatrixUtils = {
	createRealIdentityMatrix: function(dimension) {
		var m = this.createRealMatrix(dimension, dimension);
		for (var i = 0; i < dimension; ++i) {
			m.setEntry(i, i, 1.0);
		}
		return m;
	},
	createRealMatrix: function(rows, columns) {
		const Array2DRowRealMatrix = require('./Array2DRowRealMatrix');
		return (rows * columns <= 4096) ? new Array2DRowRealMatrix(rows, columns) : new BlockRealMatrix(rows, columns);
	},
	checkMatrixIndex: function(m, row, column) {
		this.checkRowIndex(m, row);
		this.checkColumnIndex(m, column);
	},
	checkRowIndex: function(m, row) {
		if (row < 0 || row >= m.getRowDimension()) {
			throw new OutOfRangeException(LocalizedFormats.ROW_INDEX, row, 0, m.getRowDimension() - 1);
		}
	},
	checkColumnIndex: function(m, column) {
		if (column < 0 || column >= m.getColumnDimension()) {
			throw new OutOfRangeException(LocalizedFormats.COLUMN_INDEX, column, 0, m.getColumnDimension() - 1);
		}
	},
	checkMultiplicationCompatible: function(left, right) {
		if (left.getColumnDimension() != right.getRowDimension()) {
			throw new DimensionMismatchException(left.getColumnDimension(), right.getRowDimension());
		}
	}
}

module.exports = MatrixUtils
